<%
String encode="jpeg";
String uri=request.getRequestURI();
String myurl="http://"+request.getHeader("Host")+uri.substring(0,uri.length()-12); //12 ist the length of my page name
String dataFile="combined2Positions.txt";

System.out.println("URI= " + request.getRequestURI());
System.out.println("host= " + request.getHeader("Host"));

if (request.getParameter("chart")!=null) dataFile=request.getParameter("chart");

response.setContentType("image/"+encode);
response.setDateHeader ("Expires",0);

// get output stream
java.io.OutputStream outb=response.getOutputStream();

	
// size of the chart image		   
int w=500;
int h=500;


// create Chart from data file
com.java4less.rchart.ChartLoader loader=new com.java4less.rchart.ChartLoader();
loader.loadFromFile(myurl+dataFile,false);
com.java4less.rchart.Chart chart=loader.build(false,false);

// set size of the chart
chart.setSize(w,h);

// encode image and send output to the browser
chart.saveToFile(outb,encode);			
outb.close();


%>